package StudentDemon;

public class StudentBiz {
    //{张三，李四，王五，null，......null}
Student [] students=new Student[30];
//增加，将学生对象，放入第一个为null的地方
    public void addStudent(Student student)
    {
        int index=-1;
        for(int i=0;i<students.length;i++)
        {
            if(students[i]==null)
            {
                index=i;
                break;
            }
        }
        if(index==-1)
        {
            System.out.println("数组元素已满");
        }
        else
        {
            //增加
            students[index]=student;
        }

    }
public  void ShowStudent()
{
    for(int i=0;i<students.length;i++)
    {
        if(students[i]!=null)
        {
            System.out.println("姓名为："+students[i].getName()+"\t"+"年龄为"+students[i].getAge());
        }
    }
}


}
